package cn.edu.xmu.orderpayment.order.model.retvo;

import cn.edu.xmu.orderpayment.order.model.enums.DocumentType;
import cn.edu.xmu.orderpayment.order.model.enums.OrderState;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;


import java.time.ZonedDateTime;

/**
 * @author Yujie Lin
 * @date 2021/12/10 10:05
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class NewOrderRetVo {
    private String OrderSn;
    private Byte documentType;
    private String descr;
    private Long amount;
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "uuuu-MM-dd'T'HH:mm:ss.SSSZZZZZ")
    private ZonedDateTime beginTime;
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "uuuu-MM-dd'T'HH:mm:ss.SSSZZZZZ")
    private ZonedDateTime endTime;

    public DocumentType getDocumentType() {
        return DocumentType.getTypeByCode(Integer.valueOf(documentType));
    }

    public void setDocumentType(DocumentType type) {
        this.documentType=type.getCode().byteValue();
    }
}
